package lanou.autohome.recommend.fragments;

import android.widget.ListView;

import lanou.autohome.basetool.BaseFragment;
import lanou.autohome.basetool.NetTool;
import lanou.autohome.R;
import lanou.autohome.URLValues;
import lanou.autohome.recommend.adapters.NewsAdapter;
import lanou.autohome.recommend.beans.NewsBean;

/**
 * Created by dllo on 16/8/15.
 * 推荐 -> 新闻
 */
public class NewsFragment extends BaseFragment {

    private ListView listView;


    @Override
    protected int setLayout() {
        return R.layout.fragment_recommend_news;
    }

    @Override
    protected void initView() {
        listView = bindVie(R.id.listView_recommend_news);
    }

    @Override
    protected void intiData() {
        final NewsAdapter newsAdapter = new NewsAdapter(getContext());
        mNetTool.getNetData(URLValues.NEWS_URL, NewsBean.class, new NetTool.NetListener<NewsBean>() {
            @Override
            public void onSuccess(NewsBean newsBean) {
                newsAdapter.setNewsBean(newsBean);
                listView.setAdapter(newsAdapter);
            }

            @Override
            public void onError(String errorMsg) {

            }
        });
    }
}
